package com.srwl.mytx.widget;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.PagerAdapter;

import java.util.List;

public class PresentAdapter extends PagerAdapter {
    private Context mContext;
    private List<RecyclerView> mData;

    public PresentAdapter(Context context , List<RecyclerView> list) {
        mContext = context;
        mData = list;
    }

    @Override
    public int getCount() {
        return mData.size();
    }


    //滑动时调用
    @Override
    public Object instantiateItem(ViewGroup container, int position) {
       // View view = View.inflate(mContext, R.layout.fragment_blank,null);


        RecyclerView recyclerView = mData.get(position);
        container.addView(recyclerView);
        return recyclerView;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        // super.destroyItem(container,position,object); 这一句要删除，否则报错
        container.removeView((View)object);
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }



}
